<?php

namespace Console\Controller;

use Common\Controller\AdminAuthController;

class JoinController extends CstBaseController
{
    private $roleLogic;
    const TABLE_NAME="Join";

    public function _initialize()
    {
        parent::_initialize();
        $this->roleLogic = A('Console/Role', 'Logic');
    }

    public function index() {
        
        $phone=trim(I('get.phone'));
        if(!empty($title)){
            $map["phone"]=array('like','%'.$phone.'%');
        }
        $state=I('get.state',0,'intval');
        if($state>0){
            $map["state"]=$state;
        }
        $list=D(static::TABLE_NAME)->where($map)->order('join_time DESC')->select();
        $this->assign('list',$list);
        $this->display();
    }

    public function edit() {
        $id = I('get.id', 0, intval);
        $activity_info = D(static::TABLE_NAME)->where('id='.$id)->find();

        $this->assign('info', $activity_info);
        $this->display();
    }
    
    public function doEdit() {
        $model = D(static::TABLE_NAME);
        $data = I('post.','','trim');
        
        $result = $model->where(array('id'=>$data['id']))->save($data);
        
        if ($result) {
            exit(successInfoFoxJson('修改成功！'));
        } else {
            exit(errorInfoFoxJson('修改失败！'));
        }
    }
}